package com.market.product.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.market.product.domain.ProductCommand;


public class ProductValidator implements Validator{
	@Override
	public boolean supports(Class<?> clazz) {
		return ProductCommand.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "product", "required");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "content", "required");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "price", "required");		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "point", "required");		
	}	
}
